class FileReadDemo{
public static void main(String[] fe)
{
String fleName = "temp.txt";
String line = null;
try{
FileReader fileReader = new FileReader(fileName);
BufferedReader bufferReader = new FileReader(fileName);
while((line = bufferdReader.readLine())!=null){
System.out.println(line);
}
bufferedReader.close();
}
catch(FileNotFoundException ex)
{
System.out.println("Unable to open file'"+filename +"'");
}
catch(IOException ex)
{
System.out.println("error reading file'"+fileName+"'");
}
}
}